﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;


namespace Domain.Common
{
    /// <summary>
    /// Repository interface. Implement this interface to implement an acceptable repository.
    /// </summary>
    /// <typeparam name="TEntity">The type of the entity.</typeparam>
    public interface IRepository<TEntity>
        where TEntity : class
    {
        /// <summary>
        /// <para>Inserts the specified entity into the repository. The Item is returned with any auto-generated
        ///  values updated</para>
        /// </summary>
        /// <param name="items">The item to add.</param>
        /// <returns>The updated item.</returns>
        TEntity Add(TEntity item);        

        /// <summary>
        /// Updates the specified entity in the repository.
        /// </summary>
        /// <param name="items">The item to update.</param>
        void Update(TEntity item);

        /// <summary>
        /// Deletes the specified entity from the repository.
        /// </summary>
        /// <param name="item">The item.</param>
        void Delete(TEntity item);

        /// <summary>
        /// Gets the entitys that match the predicates. If no predicates are specified all items are returned.
        /// </summary>
        /// <param name="predicates">The predicates.</param>
        /// <returns>An Array of TEntity</returns>
        IEnumerable<TEntity> Get(params Expression<Func<TEntity, bool>>[] predicates);        
    }
}
